Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Feature/pype 617 ue basic integration #3

Merged
merged 15 commits into from
Mar 30, 2020

Conversation

antirotor
Copy link
Member

@antirotor antirotor commented Mar 16, 2020

Pype Unreal Engine Integration

This PR implements basic support for Unreal Engine.

Requirements

Installation in Unreal

You need to compile Unreal Editor Avalon Integration plugin for your Unreal Engine version. For that you need Microsoft Visual Studio 2017 (Community Edition is 👌 ). You can either compile it manually, or just clone it somewhere and then set AVALON_UNREAL_PLUGIN to point there. This can also be set in pypeclub/pype-config in environments/unreal_4.24.json on line 2. Then during Unreal project creation when starting Unreal from ftrack task, Pype will detect presence of Binaries and Intemediate folders in plugin directory at AVALON_UNREAL_PLUGIN. If found, they will be copied to new project then and Visual Studio is not needed. Otherwise project will be set as C++ project and it will compile everything during first launch.

It will automatically enable required plugins PythonScriptPlugin and EditorScriptingUtilities.

Implementation

Implementation is multi-part. Avalon Core part implements support for loading, creating, managing and publishing instances. Pype part takes care of project setup, Unreal launching and basic pipeline for publishing StaticMesh from Maya and loading, managing and creating publish instance in Unreal.Avalon Integration Plugin is enabling Avalon in Unreal - it provides menu to control avalon functionality and provides other support functions for bridging Unreal and Avalon. And finally pype-config is providing basic support for creating correct environment.

Avalon Integration Plugin

⚠️ Python Scripting in Unreal Editor is still VERY experimental indeed. Things can (and probably should) change

Menu

This is C++ and Python code connecting Unreal Python API and Avalon Core API. Unreal doesn't support creation of new main menu items from Python so this plugin is defining new Blueprint class doing just that. Callback functions for this menu are implemented in Python part (in Content/Python/init_unreal.py) and they themselves are referencing corresponding functions in avalon-core host integration.

unreal-Annotation 2020-03-16 224046

Containers

This plugin is also providing two "container" BP classes - AssetContainer and AvalonPublishInstance container. Reason behind those two is that you cannot add metadata to folders in Unreal Editor Content Browser - and that is the only way to group assets together there.

So loading stuff from avalon will create folder with subset name, put content in it and also create AssetContainer class asset there to hold metadata.

unreal-2

There are two reasons for this: first, it holds metadata on it needed for Avalon to keep track of assets and second - it helps to easily find this container. Unreal project can have thousands of assets and iterating through them can be time consuming. But finding assets of only specific class type is much faster.

Those two classes tracks all changes in directory they reside in and provide live list of assets they are "containing" for script or Blueprint use.

unreal-3

Other

This plugin is also exposing some C++ API not available yet in Python API, implemented as UAvalonLib in C++ and AvalonHelpers in Python. There is currently only one function - set_folder_color() that can be used to set folder colors 😄 that can be normally done from UI. Caveat is that for color change take place, editor must be restarted.

Pype Integration

As work in Unreal Editor is quite different then in other DCCs there must be different approach to its support. In Unreal, there are no work scenes as files. Instead we work directly in self-contained project folder. So running Unreal Editor in specific context must include environment setup, project management and Unreal Engine version support.

Determining Unreal Engine version

Pype can autodetect installed Unreal Engine versions (at least on Windows). You can then choose per project/task what version you wish to use. This is done by enabling corresponding Avalon application in ftrack.

unreal-4

Project Setup

When launching Unreal Editor for given context, project must be prepared before Engine itself is run:

  • Project work path is determined
  • Basic project infrastructure is created
  • Avalon Integration Plugin is copied from AVALON_UNREAL_PLUGIN location. If Binaries and Intermediate are present (plugin was compiled) than simple project is created. Otherwise project is set as C++ project and will try to compile itself on Editor launch. For that you'll need Visual Studio 2017
  • Necessary plugins are enabled (Python Scripting Plugin and Editor Scripting Plugin)
  • (Optional) if set in preset as install_unreal_python_engine, it will also install and enable Unreal Engine Python. It will be pulled from PYPE_UNREAL_ENGINE_PYTHON_PLUGIN and if that is missing than it will be cloned with git from github. For that, you'll need git installed and in PATH and also Visual Studio 2017 to compile it.
⚠️ Unreal Python Engine: This plugin may not support latest Unreal Engine versions
📔 You can also trigger C++ project by setting dev_mode in presets

Avalon and Pyblish plugins

This includes basic support of Static Meshes pipeline. You can create and publish Static Meshes from Maya and load them into Unreal. There is simple validation for correct naming and checking for world orientation etc. This is not by far complete pipeline and serves as demonstration for implementing other, more advanced stuff.

Avalon Core Integration

This implements necessary host specific API in Avalon Core to support it and its tools. Mainly creating containers, imprinting them with data and discovering them.

Note about launchers

There is no need to set path to Unreal Engine as it is discovered by Pype. So only one unreal.bat or unreal shell script is needed.

Caveats

  • Unreal Editor will refresh only after Avalon windows are closed.
  • By default Unreal Editor is using Python 2.7 and ships without PyQt5 or PySide2. There is no easy way to install it there so we are depending on PySide (Qt4) installed using Unreals pip

@mkolar mkolar requested review from jakubjezek001 and removed request for jakubjezek001 March 17, 2020 14:47
@antirotor antirotor self-assigned this Mar 17, 2020
@simonebarbieri
Copy link
Contributor

I cannot compile the plugin! I get an error in AvalonLib.cpp saying that it cannot find UnrealType.h.

@antirotor
Copy link
Member Author

I cannot compile the plugin! I get an error in AvalonLib.cpp saying that it cannot find UnrealType.h.

This is usually problem with UnrealHeaderTool tool. Do you compiling it with new project created by Pype or standalone? Maybe try to create empy C++ project in Unreal Editor, copy Avalon Integration Plugin to Plugins/Avalon and start Visual Studio from editor. Then clear solution and try to build it again. Or delete all Intermediate and Binaries folder in project and plugin, right+click on .uproject file and choose Generate Visual Studio project files. I had difficult experience with build system, sometimes just cleaning manually stuff helped, sometime system restart helped, sometimes just re-launching Visual Studio helped...

@simonebarbieri
Copy link
Contributor

Maybe try to create empy C++ project in Unreal Editor, copy Avalon Integration Plugin to Plugins/Avalon and start Visual Studio from editor. Then clear solution and try to build it again.

That is exactly what I did 😅

Or delete all Intermediate and Binaries folder in project and plugin, right+click on .uproject file and choose Generate Visual Studio project files.

Just tried this and it didn't work. Still saying that UnrealType.h doesn't exist.

@simonebarbieri
Copy link
Contributor

Ok, I managed to compile it.

I had to change:

  • from #include "UnrealType.h" to #include "UObject/UnrealType.h" in AvalonLib.cpp line 4
  • comment line 76 in AvalonPublishInstance.cpp

@antirotor
Copy link
Member Author

I fixed a bug in Pype when creating new Unreal C++ project, it messed up directory creation. Please run pype clean to take effect. This prevented building of project and plugins...

@simonebarbieri this might be some paths set on my side. I am using UnrealVS extension for Visual Studio that might change few things. Commenting that line in AvalonPublishInstance.cpp is strange though. What error did it throw?

@simonebarbieri
Copy link
Contributor

@simonebarbieri this might be some paths set on my side. I am using UnrealVS extension for Visual Studio that might change few things.

I'll try to install it!

Commenting that line in AvalonPublishInstance.cpp is strange though. What error did it throw?

It was a redefinition from line 58!

@antirotor
Copy link
Member Author

It was a redefinition from line 58!

Oh, I see it now, thanks.

mkolar added a commit that referenced this pull request Mar 19, 2020
@simonebarbieri
Copy link
Contributor

Probably I'm missing something. When init_unreal.py is executed, it doesn't find the module avalon. Any suggestion?

@mkolar mkolar added this to the 2.8 milestone Mar 21, 2020
@simonebarbieri
Copy link
Contributor

Ok, I have been able to open unreal from ftrack with an action, and it seems to create the unreal project correctly.
It opens all the avalon windows, but there is a problem with the load one. When selecting any folder or task on the left column or the refresh button, it start giving this error:

LogPython: Error: Traceback (most recent call last):
LogPython: Error:   File "P:\pype-dev\pype-setup\repos\avalon-core\avalon\tools\loader\delegates.py", line 118, in paint
LogPython: Error: actualSize = option.icon.actualSize(
LogPython: Error: AttributeError
LogPython: Error: : 
LogPython: Error: 'PySide.QtGui.QStyleOptionViewItem' object has no attribute 'icon'

several times, and makes the window unusable. It doesn't list anything anymore, even by closing the window and reopening. The only way to show something again is to close Unreal and reopen the task from ftrack.

@mkolar mkolar merged commit b74b651 into develop Mar 30, 2020
@mkolar mkolar deleted the feature/PYPE-617-UE-basic-integration branch April 2, 2020 15:50
@ynbot ynbot assigned jakubjezek001 and unassigned antirotor Nov 22, 2021
iLLiCiTiT pushed a commit that referenced this pull request Dec 14, 2021
iLLiCiTiT pushed a commit that referenced this pull request Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement Enhancements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants